<!-- 订单页面 -->
<template>
  <MainFrame />
  <div>
    <el-table :data="orders"
              stripe
              style="width: 100%">
      <el-table-column width="180">
        <template #default="scope">
          <el-image :src="scope.row.goodsImgurl"
                    :fit="fit"
                    style="width:100%" />
        </template>
      </el-table-column>
      <el-table-column prop="orderTime"
                       label="订单时间"
                       width="180" />
      <el-table-column prop="goodsName"
                       label="商品名称"
                       width="180" />
      <el-table-column prop="goodsNum"
                       label="goodsNum" />
    </el-table>
  </div>
</template>

<script>
import { ref } from 'vue'
import MainFrame from '../views/MainFrame.vue'
export default {
  components: {
    MainFrame,
  },
  data() {
    return {
      orders: [],
    }
  },

  created() {
    let username = this.$store.state.user.username
    //通过用户名获取所有订单
    this.$http({
      url: '/orders/getOneByName',
      method: 'GET',
      params: {
        username: username,
      },
    }).then((success) => {
      console.log(success.data)
      this.orders = success.data
    })
  },
  setup() {},
}
</script>

<style>
</style>